//
//  ViewController.m
//  321
//
//  Created by Mac OS on 15-11-6.
//  Copyright (c) 2015年 xiongmingkai. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
{
    UILabel * l;
}
@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    self.view.backgroundColor = [UIColor redColor];
    l=[UILabel new];
    l.text = @"世界，你好！";
    [l sizeToFit];
    l.center = CGPointMake(self.view.frame.size.width/2.0,self.view.frame.size.height/2.0);
    l.textColor = [UIColor greenColor];
    
    [self.view addSubview:l];
    
    UIButton * btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    btn.frame = CGRectMake(100, 100, 200, 44);
    [btn setTitle:@"按钮" forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    
    [btn addTarget:self action:@selector(onClik:)forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];
    
    [btn setTitle:@"你按下了" forState:UIControlStateNormal];

}

- (void)onClik:(id)sender
{
    UIView * line=[[UIView alloc]initWithFrame:CGRectMake(0, 200, 0, 3)];
    line.backgroundColor = [UIColor blackColor];
    [self.view addSubview:line];
    [UIView animateWithDuration:1.6 animations:^{l.center = CGPointMake(self.view.frame.size.width/2.0, 44);
    }];
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    [UIView animateWithDuration:0.6 animations:^{l.center = CGPointMake(self.view.frame.size.width/2.0, self.view.frame.size.height -44);
    }];
    
    
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
